﻿using IOCDemo.Interfaces;
using IOCDemo.Services;
using Microsoft.Practices.Unity;

namespace IOCDemo.Containers
{
    public class UnityIOCContainer : IIOCContainer
    {
        private readonly UnityContainer unityContainer = new UnityContainer();

        public UnityIOCContainer()
        {
            unityContainer.RegisterType<ILoggingService, ConsoleLoggingService>();
            unityContainer.RegisterType<ISettingsService, XmlSettingsService>();
            unityContainer.RegisterType<ICacheService, InProcCacheService>();
            unityContainer.RegisterType<IAuditService, MockAuditService>();
            unityContainer.RegisterType<IAccountService, MockAccountService>();
            unityContainer.RegisterType<IUserService, MockUserService>();
            unityContainer.RegisterType<IBankingService, BankingService>();
            
        }

        #region IIOCContainer Members

        public T Resolve<T>()
        {
            return unityContainer.Resolve<T>();
        }

        #endregion
    }
}